
import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.RedisURI;
import io.lettuce.core.api.StatefulRedisConnection;



public class RedisTestString {
    RedisClient redisClient=RedisClient.create(RedisURI.create("redis://localhost"));
    StatefulRedisConnection<String,String> connection=redisClient.connect();
    public void link(){
        redisClient.create(RedisURI.create("redis://localhost"));
        StatefulRedisConnection<String,String> connection=redisClient.connect();
        System.out.println("连接成功");
    }

    public void insert(){
        connection.sync().set("keytest","test");
        String insertkey=connection.sync().get("keytest");
        System.out.println(insertkey);

    }
    public void delete(){
        String deletekey=connection.sync().get("keytest");
        System.out.println(deletekey);
        connection.sync().del("deletekey");

    }

    public void getKey(){
        RedisFuture<String> key=connection.async().get("Key");
        System.out.println(key);

    }
    public void finish(){
        connection.close();
        redisClient.shutdown();
    }
    public static void main(String[] args) {
       RedisTestString redisTestString=new RedisTestString();
       redisTestString.link();

    }



}
